<template>
	<div class="p-15">
		<img style="width: 100%;" src="../assets/images/top.png" alt="">
		<div class="flex-between-center wrap" style="width: 100%;">
			<img style="width: 48%;" @click="cell" src="../assets/images/menu1.png" alt="">
			<img style="width: 48%;" @click="$router.push('/litigationService')" src="../assets/images/menu2.png" alt="">
			<img style="width: 48%;" @click="dowmLoad" src="../assets/images/menu3.png" alt="">
			<img style="width: 48%;" @click="dowmLoad" src="../assets/images/menu4.png" alt="">
		</div>
		<img style="width: 100%;" src="../assets/images/middle.png" alt="">
		<div class="lawer-content">
			<div class="scroll" v-if="lsList.length">
				<div class="lawerDiv" :style="'width:' + Math.ceil(lsList.length/2)*9 + 'rem;'">
					<div class="lawer-box" v-for="(item, index) in lsList" :key="index" @click="$router.push('/lawerDetail?id=' + item.user_id)">
						<div class="lawer-tag flex-between-center" style="height:22px;">
							<div><img v-if="item.gold" src="../assets/images/jp.png" style="width:32px;height:22px;" />
								<span v-else style="color: #fff;">推荐</span></div>
						</div>
		
						<img :src="item.face" />
						<div class="lawer-name">
							{{ item.name }}/{{item.working_seniority}}年经验
						</div>
						<div class="lawer-title ellipsis1">{{ item.law_firm_name }}</div>
						<div class="wrong-box">
							<div class="column flex-between-center">
								<span v-for="data in item.certificate.slice(0, 2)" :key="data.id">{{data&&data.name}}</span>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="noMore p-15" v-if="lsList.length==0">
				{{address}}暂无律师~
			</div>
		</div>
		<img style="width: 100%;" src="../assets/images/bottom.png" alt="">
	</div>
</template>

<script>
	export default {
		data() {
			return {
				lsList: [],
				address:'',
			};
		},
		created() {
			this.$ip((data) => {
				this.address = data
				this.regionList(data);
			});
			
		},
		mounted() {
			this.basicsList()
		},
		methods: {
			//获取地区信息
			async regionList(address) {
				let [e, data] = await this.$store.dispatch('center/regionListApi');
				if (e) return;
				data.forEach(item => {
				  if (address.indexOf(item.region_name) > -1) {
				    this.basicsList(item.id);
				  }
				})
			},
			//获取展位律师
			async basicsList(regionId) {
				console.log(this.$store,"-----")
				let [e, data] = await this.$store.dispatch('lawyer/lawyerListApi', {
					regionId: 45
				});
				if (e) return;
				console.log(data)
				this.lsList = data.data.reduce((arr, item) => {
					if (item.face) {
						item.face = this.$img + item.face;
					} else {
						item.img = require("../assets/images/huiyuan.png")
					}
					item.certificate = item.certificate_type ? JSON.parse(item.certificate_type) : [];
					arr.push(item);
					return arr
				}, []);
			},
			cell(){
				let link = document.createElement('a');
				link.href = 'tel:4008001864';
				link.click()
			},
			dowmLoad(){
				let link = document.createElement('a');
				link.href = 'http://www.xjyfb.com/package/middle.html';
				link.click()
			}
		}
	};
</script>

<style>
</style>
